import request from '../utils/request'

// 历史预约记录类型定义
export interface HistoryAppointment {
  appointmentId: number
  userId: number
  doctorId: number
  timelistId: number
  status: number  // 3-已完成 4-已取消
  createTime: string
  weekday: number
  begTime: string
  endTime: string
  userName: string
  doctorName: string
  reason?: string  // 取消原因（如果有）
}

// 获取咨询师的历史预约记录（已完成/已取消）
export const getDoctorHistoryAppointments = (doctorId: number) => {
  return request<HistoryAppointment[]>({
    url: '/appointment/doctor/history',
    method: 'get',
    params: { doctorId }
  })
}

// 获取用户的历史预约记录（已完成/已取消）
export const getUserHistoryAppointments = (userId: number) => {
  return request<HistoryAppointment[]>({
    url: '/appointment/user/history',
    method: 'get',
    params: { userId }
  })
}

// 获取历史预约详情
export const getHistoryAppointmentDetail = (appointmentId: number) => {
  return request<HistoryAppointment>({
    url: `/appointment/history/${appointmentId}`,
    method: 'get'
  })
}
